#include "src/intersect/arcs_intersect.h"

double RandomDouble(double min, double max) {

    static std::mt19937 generator(static_cast<unsigned int>(std::time(nullptr)));

    std::uniform_real_distribution<> distribution(min, max);

    return distribution(generator);
}


static void GenerateTest() {

    int num_tests = 1000;
    long long min = -1.0 , max = 1.0;

    for (int i = 0; i < num_tests; i++) {

        Point center1 = { RandomDouble(min, max), RandomDouble(min, max) };
        Point center2 = { RandomDouble(min, max), RandomDouble(min, max) };
        double radius1 = RandomDouble(min, max);
        double radius2 = RandomDouble(min, max);

        double startangle1 = (RandomDouble(0, 360)) * M_PI / 180.0;
        double endangle1 = (RandomDouble(0, 180)) * M_PI / 180.0;

        double startangle2 = (RandomDouble(0, 360)) * M_PI / 180.0;
        double endangle2 = (RandomDouble(0, 180)) * M_PI / 180.0;

        Arc arc1(center1, radius1, startangle1, endangle1);
        Arc arc2(center2, radius2, startangle2, endangle2);

        std::vector<Point> arcintersections;
        std::cout << "Test " << i + 1 << ": \n";

        std::cout << std::fixed << std::setprecision(2);
        std::cout << "Arc1 cneter: (" << center1.x << ", " << center1.y << "),radius: " << radius1 << std::endl;
        std::cout << "Arc1 start angle: " << startangle1 << ",endangle: " << endangle1 << std::endl;

        std::cout << "Arc2 cneter: (" << center2.x << ", " << center2.y << "),radius: " << radius2 << std::endl;
        std::cout << "Arc2 start angle: " << startangle2 << ",endangle: " << endangle2 << std::endl;

        if (Arc::FindArcIntersections(arc1, arc2, arcintersections)) {

            for (const Point& p : arcintersections) {
                std::cout << "arc1 and arc2 inersect at:(" << p.x << ", " << p.y << ")" << std::endl;
            }
            std::cout << std::endl;
        }
        else {

            std::cout << "arc1 and arc2 do not intersect.\n" << std::endl;
        }
    }
}


int main(){
    GenerateTest();
}
